function bookName_focus() {
    if (document.sheet1.bookName.value == "请输入图书名称")
        document.sheet1.bookName.value = "";
}

function author_focus() {
    if (document.sheet1.author.value == "请输入作者")
        document.sheet1.author.value = "";
}

function press_focus() {
    if (document.sheet1.press.value == "请输入出版社")
        document.sheet1.press.value = "";
}

function bookNumber_focus() {
    if (document.sheet1.bookNumber.value == "请输入库存数量")
        document.sheet1.bookNumber.value = "";
}


function uploadBook() {
    var bookName = document.sheet1.bookName.value;
    var author = document.sheet1.author.value;
    var press = document.sheet1.press.value;
    var date = document.sheet1.date.value;
    var bookNumber = document.sheet1.bookNumber.value;

    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    // console.log(year, month, day)
    console.log(date)
        // 库存数量
    if (parseInt(bookNumber) <= 0) {
        alert("库存不得小于1，请重新输入！");
    }

    // 出版时间
    var nowDate = date.split('-')
    if (year < parseInt(nowDate[0])) {
        alert('出版日期不能晚于当前日期！');
    } else if (year == parseInt(nowDate[0])) {
        if (month < parseInt(nowDate[1])) {
            alert('出版日期不能晚于当前日期！');
        } else if (month == parseInt(nowDate)) {
            if (day < parseInt(nowDate[1])) {
                alert('出版日期不能晚于当前日期！');
            }
        }
    }
    if (bookName == "" || author == "" || press == "" || date == "" || bookNumber == "") {
        alert("内容不可为空");
    } else {
        alert('上传成功')
    }

}